<?php
class questions extends parent_class
{
	public $questions=array();
	public $teacher=0;
	
	public function __construct($is=false)
	{
		if ($is)
		{
			return $this->get_simple();
		}
	}
	
	public function get_simple()
	{
		$this->reset();
		$query="SELECT `id` FROM `questions` WHERE 1";
		if ($result=db::$db->query($query))
		{
			if ($result->num_rows>0)
			{
				while ($row=$result->fetch_object())
				{
					$this->questions[]=new question($row->id);
				}
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			$this->error(2);
		}
		
	}

	public function get_byarticle($article=0,$diff=3)
	{
		$this->reset();
		$query="SELECT `id` FROM `questions` WHERE `article`='".$article."' and `difficulty`='$diff'";
		if ($result=db::$db->query($query))
		{
			if ($result->num_rows>0)
			{
				while ($row=$result->fetch_object())
				{
					$this->questions[]=new question($row->id);
				}
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			$this->error(2);
		}
		
	}
	
	public function reset()
	{
		$this->questions=array();
	}
	
	public function returnit($str="")
	{
		if (trim($str)=="")
		{
			return false;
		}
		
		if ($this->questions)
		{
			$str2="";
			foreach($this->questions as $question)
			{
				$str2.=$question->returnit($str);
			}
			return $str2;
		}
		else
		{
			return false;
		}
	}
}
?>